﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using InHD.model;
using InHD.commands;
using System.Windows.Input;

namespace InHD.viewmodels
{
    class PageViewModel:WorkspaceViewModel
    {
        private List<InvoiceTemplate> _dataCollection = new List<InvoiceTemplate>();

        private int _rowIndex = -1;

        public List<InvoiceTemplate> InvoiceTemplateRowCollection
        {
            get
            {
                return _dataCollection;
            }
            set
            {
                if (_dataCollection != value)
                {
                    _dataCollection = value;
                    OnPropertyChanged("InvoiceTemplateRowCollection");
                }
            }
        }

        public int RowIndex
        {
            get
            {
                return _rowIndex;
            }
            set
            {
                if (_rowIndex != value)
                {
                    _rowIndex = value;
                    OnPropertyChanged("RowIndex");
                }
            }
        }

        public PageViewModel(List<InvoiceTemplate> list)
        {
            this.InvoiceTemplateRowCollection = list;
        }

        private RelayCommand _addNewInvoiceTemplateCommand;
        public ICommand AddNewInvoiceTemplateCommand
        {
            get
            {
                if (_addNewInvoiceTemplateCommand == null)
                {
                    _addNewInvoiceTemplateCommand = new RelayCommand(
                        (param) => this.AddNewInvoiceTemplate());
                }
                return _addNewInvoiceTemplateCommand;
            }
        }

        private void AddNewInvoiceTemplate()
        {
            OnRequestClose();
        }
    }
}
